package day1224;

import day1225.Test;

import java.util.Scanner;

public class Test7 {
    public static void main(String[] args) {
        //1.
        char rs=judgePrimeNum(7);
        System.out.println( rs=='Y'?   "是质数"  :  "不是质数" );

        //2.通过类名调用judgePrimeNum()
        char rs1=Test7.judgePrimeNum(90);
        System.out.println( rs1=='Y'?   "是质数"  :  "不是质数" );

        //3.new Test
        Test7  t=new Test7();
        char rs2=t.judgePrimeNum(90);
        System.out.println( rs2=='Y'?   "是质数"  :  "不是质数" );
    }

    static char judgePrimeNum(int num){
        char flag='Y';//flag变量用于表示num是否是质数(flag的值如果是Y，说明num是质数)
        for(int i=2; i<num; i++){
            if(num%i == 0){//i能整除num:证明i是num的因子,就将flag的值赋值为N表示num不是质数
                flag='N';
                break;
            }
        }

        return flag;
    }
}
